import {messages} from "share/common";
import React, { Component } from 'react';
import { Tabs, Alert } from 'antd';
import 'styles/setting/invoice-bag/invoice-bag-detail.scss';
import InvoiceBagEdit from 'containers/setting/invoice-bag/invoice-bag-edit';
import { connect } from 'react-redux';

const {TabPane} = Tabs;

class InvoiceBagCompany extends Component {
  constructor(props) {
    super(props);
  }

  render() {
    return (
      <div>
        {
          !this.props.tenantMode &&
          <Alert
            message={ messages('setting.key1805')/*注：*/ }
            description={ messages('setting.key1806')/*“公司级”规则优先级高于“租户级”规则*/ }
            type="warning"
            showIcon
            closable
          />
        }
        {
          this.props.tenantMode ?
            <InvoiceBagEdit roleType={ 'TENANT' }
                            invoiceBagOID={ this.props.params.invoiceBagOID }/> :
            <div className="invoice-bag-company">
              <Tabs defaultActiveKey="company" onChange={ this.handleChangeTabs }>
                <TabPane tab={ messages('setting.key1807')/*公司级规则*/ } key="company">
                  <InvoiceBagEdit configType={ 'COMPANY' }/>
                </TabPane>
                <TabPane tab={ messages('setting.key1808')/*租户级规则*/ } key="tenant">
                  <InvoiceBagEdit configType={ 'TENANT' }/>
                </TabPane>
              </Tabs>
            </div>
        }
      </div>
    );
  }
}

InvoiceBagCompany.contextTypes = {
  router: React.PropTypes.object
};

function mapStateToProps(state) {
  return {
    tenantMode: state.main.tenantMode
  };
}

export default connect(mapStateToProps)(InvoiceBagCompany);

